Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Developing Applications > Developing XPage Applications > XPage Tutorials > The JSON RPC Service
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Community articleThe JSON RPC Service
Added by ~Mary Reluveroden | Edited by ~Mary Reluveroden on June 20, 2011 | Version 5
expanded Abstract
collapsed Abstract
Use the JSON RPC Service included in the Extension Library to communicate with the server from Client Side Javascript in an XPage
Tags: xpages, rpc

The JSON RPC is included with the Extension Libraryexternal link and provides an entry point for CSJS to interact with the server. Methods inside an RPC are SSJS that can be as simple or as complex as you like. They are an excellent means of kicking off backend Java methods or just doing all the work themselves. Best of all, the JSON RPC is stupid simple to implement and a very powerful feature to enhance and speed up development by cutting down the time and code required to communicate with the server from CSJS.

 

The JSON RPC shows up in the Component Palette under "" as "Remote Service":

RPC Component

 

To use it just drag this component onto your xpage and assign the methods/arguments you need for each task that's required to be launched from CSJS. The best placement for the RPC is at the topmost layout level of your application. For example, if you have the layout that wraps the entire application and all the forms, views, pages, etc are within this layout, that's the place to put your RPC. Doing this will make the RPC available everywhere and you only have to define methods once.

 

Now that you've got the RPC service on your page, define a Service Name for the service. This name is a global CSJS variable and is what will be available for you to use in order to call the methods within the RPC. Once that's done you can add your methods and the required arguments for each method. These methods will be SSJS and have all the functionality of SSJS, which makes it a very useful tool. That's it really for the setup of the RPC. Here's what an RPC's properties look like:

RPC Properties

 

To call the methods you just created within the RPC, assuming you gave it a service name of myRPC with a method of myMethod that has 1 argument which accepts a string, you can just issue the following CSJS:

myRPC.myMethod("somevalue");
 

You can also include a callback that runs once the RPC has completed running it's method code by using the following CSJS pattern:

myRPC.myMethod("somevalue").addCallback(function(response) {
console.log("the response is " + response);
});
 

So as you can see, the JSON RPC is a great addition to the Extension Library that makes it very easy to communicate with the server from CSJS.

expanded Attachments (2)
collapsed Attachments (2)
File TypeSizeFile NameCreated OnDelete file
image/x-png 10 KB ControlsPalette.png 6/20/11, 3:32 PM
image/x-png 31 KB Properties.png 6/20/11, 3:32 PM
expanded Versions (6)
collapsed Versions (6)
Version Comparison     
VersionDateChanged by              Summary of changes
6Jun 20, 2011, 5:34:02 PM~Dana Xankroikle  
This version (5)Jun 20, 2011, 3:43:21 PM~Mary Reluveroden  
4Jun 20, 2011, 3:35:33 PM~Mary Reluveroden  
3Jun 20, 2011, 3:33:56 PM~Mary Reluveroden  
2Jun 20, 2011, 3:31:00 PM~Mary Reluveroden  
1Jun 20, 2011, 3:30:30 PM~Mary Reluveroden  
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility